package com.cloudxingkong.dianyinke.Student.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cloudxingkong.dianyinke.R;
import com.cloudxingkong.dianyinke.Student.bean.KeMuTest;

import java.util.List;

/**
 * Created by ningfei on 2016/3/28.
 */
public class KeMuGridViewAdapter extends BaseAdapter{
    private List<KeMuTest.ListBean.ChildrenBean> list;
    private Context context;
    public KeMuGridViewAdapter(List<KeMuTest.ListBean.ChildrenBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list==null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView == null) {
            convertView=View.inflate(context, R.layout.kemu_gv_item,null);
            holder=new ViewHolder();
            holder.tvType= (TextView) convertView.findViewById(R.id.gv_item_type);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }

        holder.tvType.setText(list.get(position).getName()+"");

        return convertView;
    }

    private class ViewHolder{
        TextView tvType;
    }
}
